package com.example.fang.demodruid.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.example.fang.demodruid.entity.SysOperLog;
import com.example.fang.demodruid.util.AddressUtils;
import com.example.fang.demodruid.util.SpringUtils;

import java.util.TimerTask;

/**
 * <p>
 * 操作日志记录 服务类
 * </p>
 *
 * @author fangchen
 * @since 2022-07-14
 */
public interface ISysOperLogService extends IService<SysOperLog> {

    /**
     * 操作日志记录
     * @param operLog
     * @return
     */
    public static TimerTask recordOper(final SysOperLog operLog) {
        return new TimerTask() {
            @Override
            public void run() {
                // 远程查询操作地点
                operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
                SpringUtils.getBean(ISysOperLogService.class).save(operLog);
            }
        };
    }


}
